package com.f21.f21assessoria.service;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.f21.f21assessoria.dao.CrudDao;
@Service
public abstract class CrudServImp<T> implements Serializable {

	private static final long serialVersionUID = 1L;


	private static final Logger logger = Logger.getLogger(CrudServImp.class);
			
	public abstract CrudDao<T> getDAO();
	
	@Transactional
	public void salvar(T obj) {
		getDAO().salvar(obj);
	}

	public void editar(T obj) {
		
	}
	
	public void excluir(T obj){
		getDAO().excluir(obj);
	}

	public T buscarPorId(long id) {
		
		return getDAO().buscarPorId(id);
	}

	public  List<T> listarTodos() {
		return getDAO().listarTodos();
	}
	
	public List<T> listarTodos(String classe) {
		ArrayList<T> lista = (ArrayList<T>) getDAO().listarTodos(classe);
		return lista;
	}
	
	public List getExecQuery(String query){
		return getDAO().getExecQuery(query);
	}
}
